← Index
NYTProf Performance Profile   
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:33:30 2016

Filename(eval 1176)[/usr/share/perl5/CGI/Compile.pm:12]
StatementsExecuted 0 statements in 0s
Eval Invoked At/usr/share/perl5/CGI/Compile.pm line 12
Sibling evals1, 2
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11138µs64µsCGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::::BEGIN@2CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@2
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl;sub {local $CGI::Compile::USE_REAL_EXIT = 0;
25249µs
# spent 64µs (38+25) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@2 which was called: # once (38µs+25µs) by CGI::Compile::_eval at line 2
CGI::initialize_globals() if defined &CGI::initialize_globals;local ($0, $CGI::Compile::_dir, *DATA);{ my ($data, $path, $dir) = @_[1..3];$0 = $path;$CGI::Compile::_dir = File::pushd::pushd $dir;open DATA, '<', \$data;}local @SIG{keys %SIG} = do { no warnings 'uninitialized'; @{[]} = values %SIG };local $^W = 0;my $rv = eval {local @ARGV = @{ $_[4] };local @_ = @{ $_[4] };
# spent 117µs making 1 call to File::pushd::pushd # spent 64µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@2 # spent 26µs making 1 call to warnings::unimport # spent 25µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:open # spent 18µs making 1 call to CGI::initialize_globals
3#line 1 /home/vagrant/kohaclone/circ/ysearch.pl
4#!/usr/bin/perl
5
6# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
7
8# Copyright 2007 Tamil s.a.r.l.
9# Parts copyright 2010-2012 Athens County Public Libraries
10#
11# This file is part of Koha.
12#
13# Koha is free software; you can redistribute it and/or modify it
14# under the terms of the GNU General Public License as published by
15# the Free Software Foundation; either version 3 of the License, or
16# (at your option) any later version.
17#
18# Koha is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with Koha; if not, see <http://www.gnu.org/licenses>.
25
26=head1 ysearch.pl
27
28=cut
29
30use Modern::Perl;
31use CGI qw ( -utf8 );
32use C4::Context;
33use C4::Auth qw/check_cookie_auth/;
34use Koha::Borrowers;
35use Koha::DateUtils qw/format_sqldatetime/;
36
37use JSON qw( to_json );
38
39my $input = new CGI;
40my $query = $input->param('term');
41
42binmode STDOUT, ":encoding(UTF-8)";
43print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
44
45my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { circulate => '*' } );
46if ( $auth_status ne "ok" ) {
47 exit 0;
48}
49
50my $limit_on_branch;
51if ( C4::Context->preference("IndependentBranches")
52 && C4::Context->userenv
53 && !C4::Context->IsSuperLibrarian()
54 && C4::Context->userenv->{'branch'} ) {
55 $limit_on_branch = 1;
56}
57
58my @parts = split( / /, $query );
59my @params;
60foreach my $p (@parts) {
61 push(
62 @params,
63 -or => [
64 surname => { -like => "%$p%" },
65 firstname => { -like => "%$p%" },
66 cardnumber => { -like => "$p%" },
67 ]
68 );
69}
70
71push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
72
73my $borrowers_rs = Koha::Borrowers->search(
74 { -and => \@params },
75 {
76 # Get the first 10 results
77 page => 1,
78 rows => 10,
79 order_by => [ 'surname', 'firstname' ],
80 },
81);
82
83my @borrowers;
84while ( my $b = $borrowers_rs->next ) {
85 push @borrowers,
86 { borrowernumber => $b->borrowernumber,
87 surname => $b->surname // '',
88 firstname => $b->firstname // '',
89 cardnumber => $b->cardnumber // '',
90 dateofbirth => format_sqldatetime($b->dateofbirth, undef, undef, 1) // '',
91 address => $b->address // '',
92 city => $b->city // '',
93 zipcode => $b->zipcode // '',
94 country => $b->country // '',
95 };
96}
97
98print to_json( \@borrowers );
99
100};
101 my $self = shift;
102 my $exit_val = unpack('C', pack('C', sprintf('%.0f', $rv)));
103 if ($@) {
104 die $@ unless (
105 ref($@) eq 'ARRAY' and
106 $@->[0] eq "EXIT\n"
107 );
108 my $exit_param = unpack('C', pack('C', sprintf('%.0f', $@->[1])));
109
110 if ($exit_param != 0 && !$CGI::Compile::RETURN_EXIT_VAL && !$self->{return_exit_val}) {
111 die "exited nonzero: $exit_param";
112 }
113
114 $exit_val = $exit_param;
115 }
116
117 return $exit_val;
118 };
119;